export default {
  install(Vue, options) {
    Vue.prototype.$close = function() {
      this.$emit('close')
    }
    Vue.prototype.$reload = function() {
      this.$emit('reload')
    }
    Vue.prototype.$ERROR = function(msg) {
      this.$message({ type: 'error', message: msg })
    }
    Vue.prototype.$WARNING = function(msg) {
      this.$message({ type: 'warning', message: msg })
    }
    Vue.prototype.$SUCCESS = function(msg) {
      this.$message({ type: 'success', message: msg })
    }
    /**
     * setDialog 设置dialog
     * @visible [Boolean] 设置dialog是否显示
     * @title [String] 设置dialog标题
     * @mode [Boolean] 设置isEditMode
     * */
    Vue.prototype.$setDialog = function(visible, title, mode) {
      this.dialog = visible
      this.title = title
      this.isEditMode = mode
    }
    /**
     * sort 对列表的order进行降序
     * @list [Array] 列表数组
     * */
    Vue.prototype.$sort = function(list) {
      list.sort(function(a, b) {
        return a.order - b.order
      })
    }
  }
}
